#include "unittest4.h"
void testEndTurn(struct gameState *state,int player){
    int result,failed_tests=0;
    result = endTurn(state);
    int turn = whoseTurn(state);
    if(result !=0 || turn == player){
        printf("failed to change turn for %i\n",player);
        failed_tests+=1;
    }
    else{
        int newPlayer = whoseTurn(state);
        if(state->handCount[player]!=0){
            printf("Failed to discard hand for player %i\n",player);
            failed_tests+=1;
        }
        if(state->phase !=0){
            printf("Failed to reset game phase\n");
            failed_tests+=1;
        }
        if(state->handCount[newPlayer] !=5){
            printf("Failed to draw 5 cards for next player\n");
            failed_tests+=1;
        }
        if(state->numActions !=1){
            printf("Failed to reset number of actions\n");
             failed_tests+=1;
        }
        if(state->coins!=0){
            printf("Failed to reset coins for player %i\n",turn);
            failed_tests+=1;
        }
        if(state->numBuys!=1){
            printf("Failed to reset buys for player %i\n",turn);
            failed_tests+=1;
        }
        if(state->playedCardCount!=0){
            printf("Failed to reset played card count for player %i\n",turn);
            failed_tests+=1;
        }
        
    }
    if(failed_tests==0){
        printf("All tests for endTurn passed\n");
    }
    else{
        printf("Number of failed tests for endTurn %i for player %i \n",failed_tests,player);
    }
}
int main(int argc, char** argv){
    int cards[10] = {adventurer, council_room, feast, gardens, mine,
        remodel, smithy, village, baron, great_hall};
    
    struct gameState* game =newGame();
    int initialized = initializeGame(2,cards,42,game);
    if(initialized!=-1){
        //testing initial case to see if it turns over for both players correctly
        testEndTurn(game,0);
        testEndTurn(game,1);
    }
    return 0;
    
}